﻿using System;
using System.Collections.Generic;
using Framework;

namespace Enterprise.Admin.Handle
{
    /// <summary>
    /// 获取应聘列表JSON
    /// </summary>
    public partial class GetCandidatesListjson : AdminBasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            var datas = new List<object>();
            var post = Fq("CoPost").SafeToString();
            var mobile = Fq("CoMobile").SafeToString();
            var phone = Fq("CoPhone").SafeToString();
            var isRead = Fq("CoIsRead").SafeToString();
            var pageValue = Fq("page").SafeToInt();
            var rowsValue = Fq("rows").SafeToInt();
            var candidatesService = new CandidatesService();
            var table = candidatesService.GetTable(post, mobile, phone, isRead, pageValue, rowsValue);
            object result = new { total=table.Total, rows = datas };
            for (int i = 0; i < table.Rows.Count; i++)
            {
                datas.Add(new
                {
                    id = table.Rows[i]["CoCandidatesId"].SafeToInt(),
                    CoPost = table.Rows[i]["CoPost"].SafeToString(),
                    CoName = table.Rows[i]["CoName"].SafeToString(),
                    CoAge = table.Rows[i]["CoAge"].SafeToString(),
                    CoIsRead = table.Rows[i]["CoIsRead"].SafeToBool(),
                    CoSex = table.Rows[i]["CoSex"].SafeToString(),
                    CoMobile = table.Rows[i]["CoMobile"].SafeToString(),
                    CoPhone = table.Rows[i]["CoPhone"].SafeToString(),
                    CoDate = table.Rows[i]["CoDate"].SafeToDateTime().ToString("yyyy-MM-dd"),
                });
            }
            Json(result);
        }
    }
}